{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\burlacue\Dropbox\Corruption papper\DATAVERSE\marginal_effect_model5.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}19 Oct 2017, 12:25:00
{txt}
{com}. 
. **** This code can be used to generate lines "b" in Table 3 
. * "Average marginal effects of ideological proximity conditional
. *on the level of corruption, perceptual accuracy and political efficacy
. *and their 95% confidence intervals" in the article
. 
. ** The code has been generated based on Hanmer and Kalkan(2013) online Appendix
. * AJPS_602_sm_suppmatS1.docx available at 
. * http://onlinelibrary.wiley.com/doi/10.1111/j.1540-5907.2012.00602.x/abstract
. 
. * Hanmer, M. J. and K. O. Kalkan (2013). Behind the curve: Clarifying the best 
. * approach to calculating predicted probabilities and marginal effects from 
. * limited dependent variable models. American Journal of Political Science 57 (1),
. * 263–277
. 
. ***The measures for corruption should be purchased from the PRG Group. 
. *In this article, I used the monthy measures of corruption from Table 3b and 
. *calculated the annual averages:
. *forvalues i=1984/2016{c -(}
. *gen corruption`i'= _01_`i'+_02_`i'+ _03_`i'+_04_`i'+ _05_`i' + _06_`i'+ ///
> *_07_`i'+_08_`i'+ _09_`i'+_10_`i'+ _11_`i' + _12_`i'
. *{c )-}
. *drop Variable _01_1984 - _01_2017
. *reshape long corruption, i(Country) j(year)
. 
. ** These should be merged with the data. Make sure the variable is called corruption 
. 
. ** The dataset DOES NOT include a variable for corruption!!!
. 
. clear all
{txt}
{com}. 
. set mem 1000m
{txt}{bf:set memory} ignored.
{p 4 4 2}
Memory no longer
needs to be set in modern Statas;
memory adjustments are performed on the fly
automatically.
{p_end}

{com}. set maxvar 32767

{txt}
{com}. 
. set seed 99
{txt}
{com}. estimates use sem1 // See probit-models-of-vote-for-the-incumbent
{res}{txt}
{com}. 
. mat b=e(b)
{txt}
{com}. mat V=e(V)
{txt}
{com}. 
. drawnorm corruption_b ideolcor_b ideolprime_b ideoldifference_b interaction_b ///
> age_b male_b income_b loweducation_b higheducation_b unemployed_b retired_b ///
> other_b partisan_b growth_b  gdp_b durable_b partyage_b pr_b pluralty_b /// 
> mdmh_b p_effnv_b   p_maj_b  state_b east_b noneuro_b  system_b cons_b  ///
> a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 ///
> a22  a23 a24 a25 , mean(b) cov(V) n(1000)
{txt}(obs 1,000)

{com}.     
. merge using recoded_CSES_data.dta
{txt}{p}
(note: you are using old
{bf:merge} syntax; see
{bf:{help merge:[D] merge}} for new syntax)
{p_end}

{com}. 
. 
. *** Effect of ideolprime when corruption is low (0.1)
. 
. replace corruption=0.1
{txt}(60,665 real changes made)

{com}. 
. // calculate the marginal effect of ideological proximity when perceptual 
. // accuracy is low (0.66) and high (1)
.  
. foreach j of numlist 66 100 {c -(}   
{txt}  2{com}.  
.  gen eff_ideol_`j'=.
{txt}  3{com}. 
.  replace ideoldifference=`j'/100
{txt}  4{com}.  
.  
.  quietly   forvalues i=1/1000{c -(}
{txt}  5{com}.   gen p_`i'=normalden(corruption_b[`i']*corruption + ///
> ideolcor_b[`i']*ideolprime*corruption + ideolprime_b[`i']*ideolprime + ///
> ideoldifference_b[`i']*ideoldifference +  ///
> interaction_b[`i']*ideoldifference*ideolprime + age_b[`i']*age + ///
>  male_b[`i']*male + income_b[`i']*income + ///
>  loweducation_b[`i']*loweducation +  higheducation_b[`i']*higheducation + ///
> unemployed_b[`i']*unemployed + retired_b[`i']*retired + other_b[`i']*other + ///
> partisan_b[`i']*partisan + gdp_b[`i']*gdp + durable_b[`i']*durable + ///
>  partyage_b[`i']*partyage + pr_b[`i']*pr + pluralty_b[`i']*pluralty + ///
>  mdmh_b[`i']*mdmh + p_effnv_b[`i']*p_effnv +   p_maj_b[`i']*p_maj + ///
> state_b[`i']*state_b + east_b[`i']*east + noneuro_b[`i']*noneuro +  ///
> system_b[`i']*system + growth_b[`i']*growth + ///
> cons_b[`i'])*(ideolcor_b[`i']*corruption+ ideolprime_b[`i'] + ///
>  interaction_b[`i']*ideoldifference)
{txt}  6{com}. 
.  sum p_`i', meanonly
{txt}  7{com}.  
.  replace eff_ideol_`j'=r(mean) in `i'
{txt}  8{com}.  {c )-}
{txt}  9{com}.  drop p_1-p_1000
{txt} 10{com}.  
.   {c )-}
{txt}(66,987 missing values generated)
(66,987 real changes made)
(66,987 missing values generated)
(66,987 real changes made)

{com}.   
.  gen effect_lc=. // estimate
{txt}(66,987 missing values generated)

{com}.   gen effect_l_lc=. // low value of 95% confidence interval
{txt}(66,987 missing values generated)

{com}.  gen effect_u_lc=. // high value of 95% confidence interval
{txt}(66,987 missing values generated)

{com}. 
.   
. foreach k of numlist 66 100 {c -(}
{txt}  2{com}.  sum eff_ideol_`k', meanonly
{txt}  3{com}.  replace effect_lc=r(mean) in `k'
{txt}  4{com}.  centile eff_ideol_`k', centile(2.5)
{txt}  5{com}.   replace effect_l_lc=r(c_1) in `k'
{txt}  6{com}.  centile eff_ideol_`k', centile(97.5)
{txt}  7{com}.   replace effect_u_lc=r(c_1) in `k'
{txt}  8{com}.   {c )-}
{txt}(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideol_66 {c |}{col 14}{res}     1,000{col 29}    2.5{col 39} .0163265{col 55} .0157028{col 67} .0168501{txt}
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideol_66 {c |}{col 14}{res}     1,000{col 29}   97.5{col 39} .0321637{col 55} .0315266{col 67} .0329092{txt}
(1 real change made)
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideo~100 {c |}{col 14}{res}     1,000{col 29}    2.5{col 39} .0349672{col 55} .0341666{col 67} .0355446{txt}
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideo~100 {c |}{col 14}{res}     1,000{col 29}   97.5{col 39} .0516547{col 55} .0511582{col 67} .0523624{txt}
(1 real change made)

{com}.   
.   
.  drop eff_ideol_66 eff_ideol_100
{txt}
{com}. 
.   
.   *** Effect of ideolprime when corruption is high (0.8)
. 
. replace corruption=0.8
{txt}(66,987 real changes made)

{com}.  
.    // calculate the marginal effect of ideological proximity when perceptual 
. // accuracy is low (0.66) and high (1)
.  
. foreach j of numlist 66 100 {c -(}   
{txt}  2{com}.  
.  gen eff_ideol_`j'=.
{txt}  3{com}. 
.  replace ideoldifference=`j'/100
{txt}  4{com}.  
.  quietly   forvalues i=1/1000{c -(}
{txt}  5{com}.   gen p_`i'=normalden(corruption_b[`i']*corruption + ///
> ideolcor_b[`i']*ideolprime*corruption + ideolprime_b[`i']*ideolprime + ///
> ideoldifference_b[`i']*ideoldifference +  ///
> interaction_b[`i']*ideoldifference*ideolprime + age_b[`i']*age + ///
>  male_b[`i']*male + income_b[`i']*income + ///
>  loweducation_b[`i']*loweducation +  higheducation_b[`i']*higheducation + ///
> unemployed_b[`i']*unemployed + retired_b[`i']*retired + other_b[`i']*other + ///
> partisan_b[`i']*partisan + gdp_b[`i']*gdp + durable_b[`i']*durable + ///
>  partyage_b[`i']*partyage + pr_b[`i']*pr + pluralty_b[`i']*pluralty + ///
>  mdmh_b[`i']*mdmh + p_effnv_b[`i']*p_effnv +   p_maj_b[`i']*p_maj + ///
> state_b[`i']*state_b + east_b[`i']*east + noneuro_b[`i']*noneuro +  ///
> system_b[`i']*system + growth_b[`i']*growth + ///
> cons_b[`i'])*(ideolcor_b[`i']*corruption+ ideolprime_b[`i'] + ///
>  interaction_b[`i']*ideoldifference)
{txt}  6{com}.  
.  sum p_`i', meanonly
{txt}  7{com}.  
.  replace eff_ideol_`j'=r(mean) in `i'
{txt}  8{com}.  {c )-}
{txt}  9{com}.  drop p_1-p_1000
{txt} 10{com}.  
.   {c )-}
{txt}(66,987 missing values generated)
(66,987 real changes made)
(66,987 missing values generated)
(66,987 real changes made)

{com}.   
.  gen effect_hc=. // estimate
{txt}(66,987 missing values generated)

{com}.   gen effect_l_hc=. //low value of 95% confidence interval
{txt}(66,987 missing values generated)

{com}.  gen effect_u_hc=. // high value of 95% confidence interval
{txt}(66,987 missing values generated)

{com}. 
.   
. foreach k of numlist 66 100 {c -(}
{txt}  2{com}. local g=`k'+1
{txt}  3{com}.  sum eff_ideol_`k', meanonly
{txt}  4{com}.  replace effect_hc=r(mean) in `k'
{txt}  5{com}.  centile eff_ideol_`k', centile(2.5)
{txt}  6{com}.   replace effect_l_hc=r(c_1) in `k'
{txt}  7{com}.  centile eff_ideol_`k', centile(97.5)
{txt}  8{com}.   replace effect_u_hc=r(c_1) in `k'
{txt}  9{com}.   {c )-}
{txt}(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideol_66 {c |}{col 14}{res}     1,000{col 29}    2.5{col 39} .0118714{col 55} .0111896{col 67} .0123296{txt}
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideol_66 {c |}{col 14}{res}     1,000{col 29}   97.5{col 39} .0248637{col 55} .0245096{col 67} .0256383{txt}
(1 real change made)
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideo~100 {c |}{col 14}{res}     1,000{col 29}    2.5{col 39} .0297143{col 55} .0285005{col 67} .0306321{txt}
(1 real change made)

{col 56}{hline 2} Binom. Interp. {hline 2}
    Variable {c |}       Obs  Percentile    Centile        [95% Conf. Interval]
{hline 13}{c +}{hline 61}
eff_ideo~100 {c |}{col 14}{res}     1,000{col 29}   97.5{col 39}  .049292{col 55}   .04866{col 67} .0499624{txt}
(1 real change made)

{com}.   
.   *** The marginal effect of ideological voting when:
.   
.   * low perceptual accuracy, low corruption: 
. list effect_lc effect_l_lc effect_u_lc in 66
{txt}
     {c TLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c TRC}
     {c |} {res}eff~t_lc   eff~l_lc   eff~u_lc {txt}{c |}
     {c LT}{hline 10}{c -}{hline 10}{c -}{hline 10}{c RT}
 66. {c |} {res}.0238524   .0163265   .0321637 {txt}{c |}
     {c BLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c BRC}

{com}. 
.   * low perceptual accuracy, high corruption: 
. list effect_hc effect_l_hc effect_u_hc in 66  
{txt}
     {c TLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c TRC}
     {c |} {res}eff~t_hc   eff~l_hc   eff~u_hc {txt}{c |}
     {c LT}{hline 10}{c -}{hline 10}{c -}{hline 10}{c RT}
 66. {c |} {res}.0181508   .0118714   .0248637 {txt}{c |}
     {c BLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c BRC}

{com}. 
.    * high perceptual accuracy, low corruption: 
. list effect_lc effect_l_lc effect_u_lc in 100
{txt}
     {c TLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c TRC}
     {c |} {res}eff~t_lc   eff~l_lc   eff~u_lc {txt}{c |}
     {c LT}{hline 10}{c -}{hline 10}{c -}{hline 10}{c RT}
100. {c |} {res}  .04386   .0349672   .0516547 {txt}{c |}
     {c BLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c BRC}

{com}.   
.    * high perceptual accuracy, high corruption: 
. list effect_hc effect_l_hc effect_u_hc in 100
{txt}
     {c TLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c TRC}
     {c |} {res}eff~t_hc   eff~l_hc   eff~u_hc {txt}{c |}
     {c LT}{hline 10}{c -}{hline 10}{c -}{hline 10}{c RT}
100. {c |} {res}.0394516   .0297143    .049292 {txt}{c |}
     {c BLC}{hline 10}{c -}{hline 10}{c -}{hline 10}{c BRC}

{com}. 
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\burlacue\Dropbox\Corruption papper\DATAVERSE\marginal_effect_model5.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}19 Oct 2017, 12:30:29
{txt}{.-}
{smcl}
{txt}{sf}{ul off}